package com.lvmama.controller.rhino.tree;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lvmama.client.rhino.TreeStatisticsClient;
import com.lvmama.common.utils.DateUtil;
import com.lvmama.pojo.dto.rhino.tree.TreeChartDTO;
import com.lvmama.pojo.entity.rhino.tree.TreeNodeView;

@Controller
@RequestMapping("treeChart")
public class TreeStatisticsController {
    
    @Autowired
    private TreeStatisticsClient client;
    
    @RequestMapping(value = "tree",method = RequestMethod.GET)
	public String home(ModelMap model){
    	//设置页面的默认时间,今天和七天前
    	model.addAttribute("beginDate", DateUtil.getBeforeDays(7));
    	model.addAttribute("endDate", DateUtil.getYesterday());
		return "rhino/tree/FlowStatisticsTree";
	}
    
    /**
     * 
    * @Title: QueryTreeStructureFlow 
    * @Description: 初始化树的结构
     */
    @RequestMapping(value = "queryStructureFlow",method = RequestMethod.GET)
    @ResponseBody
    public Map queryStructureFlow(TreeChartDTO dto){
    	return client.queryStructureFlow(dto).getData();
    }

    /**
     * 
    * @Title: QueryNodeDatabyNode 
    * @Description: 查询树节点的流量包数据
    * @return Map    返回类型
     */
    @RequestMapping(value = "queryDataByNode",method = RequestMethod.GET)
    @ResponseBody
    public Map queryDataByNode(TreeChartDTO dto){
    	return client.queryDataByNode(dto).getData();
    }
    
    /**
     * 
    * @Title: QueryChildrenRateAndCount 
    * @Description: 查询树节点的数量和占比
    * @return TreeNodeView    返回类型
    * @throws
     */
    @RequestMapping(value = "queryChildren",method = RequestMethod.GET)
    @ResponseBody
    public TreeNodeView queryChildrenRateAndCount(TreeChartDTO dto){
    	return client.queryChildrenRateAndCount(dto).getData();
    }
}
